Encapsulation techniques are commonly used in packet communications. For example, a first packet produced according to a first packet communication protocol can be encapsulated by prepending thereto a packet header corresponding to a second packet communication protocol. The result is an encapsulation packet. The prepended header is also referred to herein as an encapsulating header, and the first packet is also referred to herein as an encapsulated packet. Thus, the encapsulation packet consists of an encapsulating header and a payload, and the encapsulated packet is the payload.
Encapsulation is utilized in various conventional packet communication applications, for example in the OSI hierarchical layered model. In the OSI hierarchical model, a layer 2 packet is an encapsulation packet produced by prepending a layer 2 header to a layer 3 packet, thereby encapsulating the layer 3 packet. In the OSI model, layer 2 represents the data link layer whose primary responsibility in networked communication is to perform encoding/decoding for packet integrity and to deliver packets “in order” to layer 3. In terms of packet processing, layer 2 represents the switching layer, wherein packets are processed based on layer 2 MAC (media access control) addresses.
Layer 3 of the OSI architecture model is the routing layer or network layer. This is the layer that runs shortest/optimal path routing algorithms. Layer 3 performs the function of end-to-end delivery of each packet through various nodes.
Any layer 2 device includes a mechanism which sends/receives packets to/from layer 3 to complete the termination function.
Layer 3 is often implemented in part through invocation of an embedded processor or a dedicated network processor. As mentioned above, among other functions, layer 3 can run a routing algorithm to determine an optimal switching route for packets from a source IP address to a destination IP address. At each termination and switching point within the communication network, the layer 2 (MAC) addresses in the layer 2 header are updated so that the packet(s) will travel correctly from point to point along the associated switching route produced by the routing algorithm. The aforementioned layer 2 addresses are carried in the layer 2 header which has been prepended to the layer 3 packet in order to encapsulate the layer 3 packet.
Furthermore, in order to support logical groupings of addresses and multicasting, the aforementioned layer 2 address can be dependent on the layer 3 IP address, which layer 3 IP address is carried in the header of the encapsulated layer 3 packet. Thus, in conventional layer 2/layer 3 OSI operations, information from within the encapsulated (layer 3) packet may be needed in order to produce the encapsulating (layer 2) header. The position of the layer 3 IP address is not necessarily fixed within the layer 3 packet. The position of the layer 3 IP address depends on the protocol that is being run at layer 3. Different layer 3 protocols position the layer 3 IP address at different locations within the layer 3 packet. Moreover, even with a fixed protocol, a protocol version upgrade or change can cause the position of the layer 3 IP address to change within the layer 3 packet. An example of a protocol change would be when the protocol moves from IPV4 to IPV6.
Thus, in some conventional layer 2/layer 3 OSI operations, the layer 2 device, in order to generate the layer 2 address, must be able to obtain the layer 3 IP address from various possible positions within the layer 3 packet.
FIG. 1 illustrates a conventional example of modifying the encapsulating header of an encapsulation packet based on information within the encapsulated packet. In the example of FIG. 1, an original encapsulation packet 11, in this example, a layer 2 packet whose payload is a layer 3 packet, is transformed into a resulting encapsulation packet 13, again, in this example, a layer 2 packet whose payload is a layer 3 packet. In FIG. 1, the reference character L2 designates layer 2, and the reference character L3 designates layer 3. In the example of FIG. 1, the data channel is eight bytes wide, and the packets 11 and 13 are therefore formatted as a sequence of 8-byte wide parallel data segments or doublewords, beginning with the first (top in FIG. 1) doubleword of the layer 2 header and thereafter continuing with the remaining doublewords from top to bottom as shown in FIG. 1. The layer 2 packets at 11 and 13 in FIG. 1 can consist of, for example, 64 bytes (8 doublewords) or 128 bytes (16 doublewords). The layer 2 header includes two 2-byte RPR headers designated as HDR1 and HDR2, a six-byte source address, and two-bytes of HEC.
In the example of FIG. 1, the resulting encapsulation packet 13 is obtained from the original encapsulation packet 11 by modifying predetermined bytes of the encapsulating (layer 2) header based on information within the encapsulated (layer 3) packet. More particularly, three predetermined bytes D in the layer 2 destination address of the encapsulating (layer 2) header are replaced by three consecutive bytes from the layer 3 IP destination address of the encapsulated (layer 3) packet, thereby producing the resulting packet 13. However, and as mentioned above, the layer 3 IP destination address (designated by reference numerals 3) can be positioned differently within the layer 3 packet according to the different available layer 3 protocols, and even according to different versions of a fixed protocol.
Accordingly, the transformation from the original encapsulation packet 11 to the resulting encapsulation packet 13 must be able to locate the desired, flexibly positionable bytes of the layer 3 IP destination address. Some conventional approaches to this problem use the “brute force” solution of providing a unique design for each possible layer 3 protocol or version thereof. Other conventional approaches attempt to guess the layer 3 protocol that is being used, and some even transfer the function to software, which is inherently slow.
It is desirable in view of the foregoing to provide the capability of modifying an encapsulating header based on information that is flexibly positionable within the encapsulated packet, while also avoiding the aforementioned difficulties of conventional approaches.